package com.lyl.module.api.client;

import cn.hutool.json.JSONObject;
import com.dtflys.forest.annotation.JSONBody;
import com.dtflys.forest.annotation.Post;
import com.dtflys.forest.annotation.Var;
import com.lyl.module.constant.AliYunUrlConstant;

import java.util.Map;

/**
 * @author 97134
 * @desc 文件Api
 */
public interface FileApiClient {

    /**
     * 获取文件列表
     *
     * @param map 请求参数
     * @return jsonObject
     */
    @Post(url = AliYunUrlConstant.FILE_LIST, headers = {
            "authorization: ${authorization}"
    })
    JSONObject getFileList(@JSONBody Map<String, Object> map);

    /**
     * 获取文件列表
     *
     * @param map 请求参数
     * @return jsonObject
     */
    @Post(
            url = AliYunUrlConstant.FILE_LIST,
            headers = {"authorization: ${authorization}"},
            data = "{\"drive_id\":\"${drive_id}\",\"parent_file_id\":\"${parentId}\",\"limit\":${limit},\"order_by\":\"updated_at\",\"order_direction\":\"DESC\"}",
            contentType = "application/json"
    )
    JSONObject getFileListV2(@Var("parentId")String parentId,@Var("limit") Integer limit);

    @Post(
            url = AliYunUrlConstant.FILE_LIST,
            headers = {"authorization: ${authorization}"},
            data = "{\"drive_id\":\"${drive_id}\"}",
            contentType = "application/json"
    )
    JSONObject getFileListV3(@JSONBody Map<String, Object> map);

    /**
     * 上传文件
     * @param map 请求参数
     * @return JSONObject
     */
    @Post(url = AliYunUrlConstant.CREATE_FILE_URL, headers = {
            "Content-Type: text/plain",
            "authorization: ${authorization}"
    })
    JSONObject uploadFile(@JSONBody(partContentType = "text/plain") Map<String, Object> map);

    /**
     * 合并上传的分片
     * @param map 请求参数
     * @return JSONObject
     */
    @Post(url = AliYunUrlConstant.COMPLETE_FILE, headers = {
            "authorization: ${authorization}"
    })
    JSONObject completeFile(@JSONBody Map<String, Object> map);
}
